package kr.or.common.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class SideMenuCheckInterceptor extends HandlerInterceptorAdapter {
	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
		String[] arrTemp = request.getRequestURI().split("/");
		
		String strFirstURI = "";
		String strSecondURI = "";
		String strThirdURI = "";
		String strFourthURI = "";
		
		if (arrTemp.length == 3) {
			strFirstURI = arrTemp[1];
			strSecondURI = arrTemp[2];
			strThirdURI = "";
			strFourthURI = "";
		} 
		else if (arrTemp.length == 4) {
			strFirstURI = arrTemp[1];
			strSecondURI = arrTemp[2];
			strThirdURI = arrTemp[3];
			strFourthURI = "";
		} 
		else if (arrTemp.length >= 5) {
			strFirstURI = arrTemp[1];
			strSecondURI = arrTemp[2];
			strThirdURI = arrTemp[3];
			strFourthURI = arrTemp[4];
		} 
		else {
			strFirstURI = "home";
			strSecondURI = "";
			strThirdURI = "";
			strFourthURI = "";
		}
		
		if (modelAndView != null) {
			modelAndView.addObject("FIRST_URI", strFirstURI);
			modelAndView.addObject("SECOND_URI", strSecondURI);
			modelAndView.addObject("THIRD_URI", strThirdURI);
			modelAndView.addObject("FOURTH_URI", strFourthURI);
		}		
	}
	
	
	
}
